{% extends webapp_config['LAYOUT'] %}

{% block meta_copydoc %}{% endblock %}

{# TODO: title, meta, etc #}
{% block meta_title %}{{ publisher }} in the Snap Store{% endblock %}
{% block meta_description %}Install {{ publisher }} software for Linux in the Snap Store{% endblock %}

{% if icon_url %}
  {% block meta_image %}
    {{ icon_url }}
  {% endblock %}
{% endif %}


{% block content %}
  <div class="p-strip--dark is-shallow" style="background: #262626">
    <div class="u-fixed-width">
      <div class="p-snap-heading">
        {% if icon_url %}
          <img class="p-snap-heading__icon" src="{{ icon_url }}" alt="{{ publisher }} snap" />
        {% else %}
          <img class="p-snap-heading__icon" src="https://assets.ubuntu.com/v1/6fbb3483-snapcraft-default-snap-icon.svg" alt="" />
        {% endif %}
        <div class="p-snap-heading__title">
          <h1 class="p-heading--two p-snap-heading__name">{{ publisher }}</h1>
          <p class="p-snap-heading__publisher">
            ({{ username }})
            {% if developer_validation and developer_validation == VERIFIED_PUBLISHER %}
            <span class="p-verified p-tooltip p-tooltip--top-center" aria-describedby="{{ username }}-tooltip">
              <img src="https://assets.ubuntu.com/v1/75654c90-rosette.svg" />
              <span class="p-tooltip__message u-align--center" role="tooltip" id="{{ username }}-tooltip">Verified account</span>
            </span>
            {% endif %}
          </p>
        </div>

        <div class="p-snap-install-buttons">
          {% if website %}
            <a href="{{ website }}" class="p-button--positive p-link--external p-snap-install-buttons__versions">Visit publisher website</a>
          {% endif %}
          {% if contact %}
            <a href="{{ contact }}" class="p-button--neutral p-link--external p-snap-install-buttons__install">Contact publisher</a>
          {% endif %}
        </div>

      </div>
    </div>
  </div>

  {% if banner_url %}
  <section
    class="p-strip--image is-deep"
    style="background-image:url('{{ banner_url }}');">
  </section>
  {% endif %}


  <div class="p-strip is-shallow">
    <div class="row">
      <div class="col-8">
        {% if summary %}<h4>{{ summary }}</h4>{% endif %}
        {{ description | safe }}
      </div>
      <div class="col-4">
        <h4>About {{ publisher }}</h4>
        <dl>
          <dt>Snaps published</dt>
          <dd>{{ snaps|length + featured_snaps|length }}</dd>
          <dt>Publisher since</dt>
          <dd>{{ publisher_since }}</dd>
        </dl>
      </div>
    </div>
  </div>

  {% if blog_slug %}
  <div data-js="blog-articles" style="display: none;">
    <div class="u-fixed-width">
      <hr />
    </div>
    <div class="p-strip is-shallow">
      <div class="row">
        <div class="col-3">
          <h3 class="p-heading--four">Related blog posts</h3>
        </div>
      </div>
      <div class="row u-equal-height" data-js="blog-article-list" data-snap="{{ blog_slug }}">
      </div>
    </div>
  </div>
  {% endif %}

  {% if featured_snaps %}
  <div class="p-strip is-shallow">
    <div class="row u-equal-height">
        {% set snap = featured_snaps[0] %}
        {% include 'partials/_publisher-featured-snap.html' %}
        {% if featured_snaps[1] %}
        {% set snap = featured_snaps[1] %}
        {% include 'partials/_publisher-featured-snap.html' %}
        {% endif %}
      </div>
    </div>
  </div>
  {% endif %}

  <div class="p-strip is-shallow">
      <div class="row">
      {% set hide_publisher = True %}
      {% set show_summary = True %}
      {% for snap in snaps %}
        <div class="col-3">
          {% include "store/_media-object-snap-partial.html" %}
        </div>
      {% endfor %}
    </div>
  </div>

  {% if api_error %}
    <div class="row">
      <div class="col-12">
        <div class="p-notification--negative">
          <p class="p-notification__response">
            <span class="p-notification__status">Error:</span> API request failed
          </p>
        </div>
      </div>
    </div>
  {% endif %}

  {# templates #}
  {% set article_title = {'rendered': '${title}'} %}
  {% set article = {'slug': '${slug}', 'title': article_title} %}
  {% if blog_slug %}
    <script type="text/template" id="blog-article-template">
      {% include 'partials/blog-card--minimal.html' %}
    </script>
  {% endif %}

{% endblock %}

{% block scripts_includes %}
  {% if blog_slug %}
    <script src="{{ static_url('js/dist/public.js') }}" defer></script>
  {% endif %}
{% endblock %}

{% block scripts %}
  {% if blog_slug %}
    <script>
      window.addEventListener("DOMContentLoaded", function() {
        Raven.context(function () {
          try {
            snapcraft.public.snapDetailsPosts('[data-js="blog-article-list"]', '#blog-article-template', '[data-js="blog-articles"]');
          } catch(e) {
            Raven.captureException(e);
          }
        });
      });
    </script>
  {% endif %}
{% endblock %}
